package com.example.mykotlin

import cn.dev33.satoken.secure.SaSecureUtil
import com.example.mykotlin.base.auth.PoiuyCipher
import org.junit.jupiter.api.Test


class MyTest {
    @Test
    fun rsaGenerateKeyPair() =
        // 生成一对公钥和私钥，其中Map对象 (private=私钥, public=公钥)
        println(SaSecureUtil.rsaGenerateKeyPair());

    /**
     * 登录时的密码加密
     */
    @Test
    fun rsaEncryptByPassWordPublic() {
        val s = "poiuy"
        val ciphertext =
            SaSecureUtil.rsaEncryptByPublic(PoiuyCipher.PUBLIC_KEY, System.currentTimeMillis().toString() + s)
        println("被公钥加密后：$ciphertext")

    }

    /**
     * 登录时的设备号加密，防止token被盗用
     */
    @Test
    fun rsaEncryptByDevicePublic() {
        val s = "321321"
        val ciphertext =
            SaSecureUtil.rsaEncryptByPublic(PoiuyCipher.DEVICE_PUBLIC_KEY, System.currentTimeMillis().toString() + s)
        println("被公钥加密后：$ciphertext")
    }

    @Test
    fun test2() {

    }

}